package dao;

import javax.persistence.EntityManager;
import javax.persistence.Query;
import org.springframework.beans.factory.annotation.Autowired;

public class DAO {
	public Query query = null;
	@Autowired
	public EntityManager em;
	public String sql = "";
	
	public void begin(){
		if(em.isOpen()){
			if(!em.getTransaction().isActive()){
				em.getTransaction().begin();
			}
		}
	}
	
	public void commit() {
		if(em.getTransaction().isActive()){
			em.getTransaction().commit();
		}
	}
	
	public void rollback(){
		if(em.getTransaction().isActive()){
			em.getTransaction().rollback();
		}
	}
	
	
	

}
